package com.control.service.impl;

import com.control.dao.ContactMapper;
import com.control.entity.Contact;
import com.control.service.ContactService;
import com.control.util.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("ContactService")
public class ContactServiceImpl implements ContactService {

    @Autowired
    private ContactMapper contactMapper;


    @Override
    public PageData<Contact> getPage(int pageIndex, int pageSize) {
        int pageCount=contactMapper.getConCount();
        int from=(pageIndex-1)*pageSize;
        List<Contact> page=contactMapper.getAll(from,pageSize);
        PageData<Contact> pageData= new PageData<>(pageIndex,pageSize,pageCount,page);

        return pageData;
    }
}
